package com.bolt.report.business.test;

import com.bolt.report.annotation.*;
import com.bolt.report.definition.Align;
import com.bolt.report.definition.DataExpand;
import lombok.Data;

import java.math.BigDecimal;

@BeanReport(
        springDataProvider = ReportDataProvider.class,
        summary = @Summary(desc = "总计", style = @Style(align = Align.left, valign = Align.middle, bold = true),
                elements = {@Element(value = "quantity", expression = "formatnumber(sum(quantity))"),
                        @Element(value = "amount", expression = "formatnumber(sum(amount))")}
        ),
        group = @Group(desc = {"合计", "小计"},
                groups = {
                        @Element(value = "area", group = true, expend = DataExpand.DOWN),
                        @Element(value = "product", group = true, expend = DataExpand.DOWN)},
                calculate = {
                        @Element(value = "quantity", expression = "formatnumber(sum(quantity))", style = @Style(align = Align.right, valign = Align.middle)),
                        @Element(value = "amount", expression = "formatnumber(sum(amount))", style = @Style(align = Align.right, valign = Align.middle))
                })
)
@Title(value = "测试报表")
@Data
public class ProductBean {

    @Element(desc = "商品编码", width = 40, hide = true)
    private String proNum;

    @Element(desc = "区域")
    private String area;

    @Element(desc = "商品名称", width = 100)
    private String product;

    @Element(desc = "单价", expression = "formatnumber(price)")
    private BigDecimal price;

    @Element(desc = "数量", expression = "formatnumber(quantity)")
    private BigDecimal quantity;

    @Element(desc = "金额", expression = "formatnumber(quantity*price)")
    private BigDecimal amount;


}